<template>
	<view class="content">
		<!-- 顶部 -->
		<view class="top" :style="{
			'background-image': $img('https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662770530543.png'),
			'padding-top':$top()+'px'
		}">
			<view style="padding: 0rpx 30rpx 30rpx 30rpx;">
				<view class="ziti" @click="types()">
					<text :style="{
						color:szf==1?'white':'#91D5C7'
					}">简 </text>
					<text>/ </text>
					<text :style="{
						color:szf==2?'white':'#91D5C7'
					}">繁</text>
				</view>
				<image class="top_logo"
					src="https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-05/164646518855180.png" />
				<!--  -->
			</view>
		</view>
		<!-- 内容-->
		<view class="body">
			<u-swiper :height="309" mode="dot" v-if="liunb" :list="liunb"></u-swiper>
			<swiper class="swiper" :autoplay="false" @change="swiperChange" :indicator-dots="false" :current='current'
				:duration="500">
				<swiper-item>
					<view class="body1" v-if="tablist">
						<view class="body1_1"
						@click="submit(item)"
						 v-for="(item,index) in tablist.slice(0,8)" :key="index">
							<view class="">
								<image :src="item.image" />
								<text>{{item.name}}</text>
							</view>

						</view>
					</view>
				</swiper-item>
				<swiper-item>
					<view class="body1" v-if="tablist">
						<view class="body1_1"
						 @click="submit(item)"
						 v-for="(item,index) in  tablist.slice(8)" :key="index">
							<view class="">
								<image :src="item.image" />
								<text>{{item.name}}</text>
							</view>
						</view>
					</view>
				</swiper-item>
			</swiper>
			<view :class="'chexk'">
				<text :class="{
					chexk_1:true,
					chexk_2:current==0,
				}"></text>
				<text :class="{
					chexk_1:true,
					chexk_2:current==1,
				}"></text>
			</view>
			<!-- 营销 -->
			<view class="body2">
				<image @click="$to('/pagesA/myCoupon/myCoupon',1)"
					src="https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662776156589.png" mode="">
				</image>
				<image @click="$to('/pages/index/make')"
					src="https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662777386319.png" mode="">
				</image>
			</view>
			<!-- 咨询-->
			<view class="body3">
				<view class="body3_1">
					<text>{{$jf('企业讯息','企業訊息')}}</text>
					<text>{{$jf('查看更多','查看更多')}}>></text>
				</view>
				<view class="body3_2" v-for="(item,index) in list1" @click="xunxi" :key="index">
					<image :src="item.logo_image" />
				</view>
			</view>
		</view>
		<!-- 遮罩 -->
		<u-mask :show="show" @click="show = false">
			<view class="warp">
				<view class="">
					<view class="rect" @click="type=1,$store.commit('ziti',1)" :style="{
						color:szf==1?'#00795E':''
					}">简体中文</view>
					<view @click="type=2,$store.commit('ziti',2)" class="rect" :style="{
						color:szf==2?'#00795E':''
					}">繁體中文</view>
				</view>

			</view>
		</u-mask>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				text: '',
				current: 0,
				info: {},
				liunb: null,
				lunbo: [],
				checked: false,
				type: 2,
				height: '',
				show: false,
				// tablist: [{
				// 		img: 'https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662779496750.png',
				// 		name: '澳門手信'
				// 	},
				// 	{
				// 		img: 'https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662809677675.png',
				// 		name: '葡萄牙紅酒'
				// 	},
				// 	{
				// 		img: 'https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662813529575.png',
				// 		name: '澳葡嚴選'
				// 	},
				// 	{
				// 		img: 'https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662812230900.png',
				// 		name: '打折商品'
				// 	},
				// 	{
				// 		img: 'https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662825472529.png',
				// 		name: '熱銷專區'
				// 	},
				// 	{
				// 		img: 'https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662826575912.png',
				// 		name: '高傭專區'
				// 	},
				// 	{
				// 		img: 'https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662828165910.png',
				// 		name: '今日秒殺'
				// 	},
				// 	{
				// 		img: 'https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662828883783.png',
				// 		name: '澳葡文創'
				// 	},
				// 	{
				// 		img: 'https://junhe-project.oss-cn-beijing.aliyuncs.com/img/2022-03-07/164662847473045.png',
				// 		name: '澳葡文創'
				// 	},
				// ],
				list: {},
				// :0
			}
		},
		onLoad() {
		},
		computed: {
			szf(){
				return this.$store.state.ziti
			},
			tablist() {
				if (this.$store.state.ziti == 1) {
					return this.info.simple
				} else {
					return this.info.multiply
				}
			},
			list1() {
				if (this.$store.state.ziti == 1) {
					return this.list.data
				} else {
					return this.list.multiply
				}
			},
		},
		onShow() {
			// this.$store.commit("ziti",123)
			console.log(this.$store.state.ziti)
			this.getinfo()
			// const value = uni.getStorageSync('launchFlag');
			// if (value) {
			// 	uni.switchTab({
			// 		url: '/pages/index/index'
			// 	});
			// } else {
			// 	uni.navigateTo({
			// 		url: '/pages/index/guio'
			// 	})
			// }
		},
		methods: {
			submit(a){
				this.$store.commit("ka",a)
				uni.switchTab({
					url:'/pages/shopping/shopping?form'+JSON.stringify(a)
				})
			},
			async mz() {
				const data = await this.api('usermsg/transform', {
					type: 2,
					name: '测试'
				})
				console.log(data.data)
				return data.data
			},
			getinfo() {
				this.api('index/goodsList').then(res => {
					this.info = res.data
				})
				this.api('index/lunbo').then(res => {
					this.liunb = res.data
				})
				this.api('index/enterpriseList', {
					type: 1
				}).then(res => {
					this.list = res.data
				})
			},
			//轮播图的切换事件
			swiperChange(e) {
				this.current = e.target.current //获取当前轮播图片的下标, 可以给当前指示点加样式
			},
			//企业讯息查询
			xunxi() {
				this.$to('/pages/index/history')
			},
			// 微信登录
			login() {
				uni.getProvider({
					service: 'oauth',
					success: function(res) {
						console.log(res)
					}
				});
				// uni.authorize({
				// 	scope: 'scope.userInfo',
				// 	success() {
				// 	uni.getUserInfo()
				// 	},
				// 	fail(res){
				// 		console.log(res)
				// 	}
				// })
			},
			types() {
				this.show = true
				// if (this.type == 1) {
				// 	this.type = 2
				// } else {
				// 	this.type = 1
				// }
			},
		}
	}
</script>

<style lang="scss">
	::v-deep .chexk {
		text-align: center;

		.chexk_1 {
			display: inline-block;
			width: 34rpx;
			height: 13rpx;
			background: #F1F1F1;
			border-radius: 7rpx;
		}

		// @keyframes myfirst {
		// 	from {
		// 		width:0rpx;
		// 	}

		// 	to {
		// 		width: 38rpx;
		// 	}
		// }

		.chexk_2 {
			display: inline-block;
			width: 38rpx;
			height: 13rpx;
			background: #00795E;
			border-radius: 7rpx;
			animation: myfirst 1s;
		}

		// .chexk_2 {}

		.u-switch__node {
			width: 38rpx !important;
			height: 13rpx !important;
			background: #00795E;
			border-radius: 7rpx;
		}

		.u-switch[data-v-4a8c9de7] {
			width: 64rpx;
			height: 13rpx;
			border: none !important;
		}
	}

	::v-deep .chexk2 {
		.u-switch__node {
			width: 40rpx !important;
			height: 13rpx !important;
			background: #F1F1F1;
			border-radius: 7rpx;
			border: none !important;
		}

		.u-switch[data-v-4a8c9de7] {
			width: 64rpx;
			height: 13rpx;
			border: none !important;
		}
	}

	.swiper {
		// border: 1rpx solid black;
		height: 350rpx;
	}

	.warp {
		display: flex;
		align-items: center;
		justify-content: center;
		height: 100%;

		.rect {
			margin-bottom: 30rpx;
			width: 500rpx;
			height: 120rpx;
			background-color: #fff;
			text-align: center;
			line-height: 120rpx;
			border-radius: 10rpx;
			font-size: 36rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #181818;
		}

	}



	// .warp {
	// 	display: flex;
	// 	align-items: center;
	// 	justify-content: center;
	// 	height: 100%;
	// 	width: 100%;
	// 	text:nth-of-type(1) {
	// 		width: 500rpx;
	// 		height: 120rpx;
	// 		background: #FFFFFF;
	// 		border-radius: 10rpx;
	// 		text-align: center;
	// 		line-height: 120rpx;
	// 	}
	// }

	.content {
		.body {
			padding: 0rpx 30rpx 30rpx 30rpx;
			margin-top: -120rpx;

			.body3 {
				margin-top: 40rpx;

				.body3_2 {
					height: 300rpx;
					margin-top: 25rpx;
					width: 100%;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.body3_1 {
					display: flex;
					justify-content: space-between;
					align-items: center;

					text:nth-of-type(1) {
						font-size: 36rpx;
						font-family: Source Han Serif CN;
						font-weight: bold;
						color: #181818;
					}

					text:nth-of-type(2) {
						font-size: 24rpx;
						font-family: Source Han Serif CN;
						font-weight: bold;
						color: #999999;

					}
				}

			}

			.body2 {
				margin-top: 20rpx;

				image {
					width: 338rpx;
					height: 201rpx;
				}

				display: flex;
				justify-content: space-between;
			}

			.body1 {
				display: flex;
				flex-wrap: wrap;
				justify-content: space-between;
				align-items: center;

				.body1_1 {
					display: flex;
					align-items: center;
					justify-content: center;
					margin-bottom: 20rpx;
					width: 160rpx;
					text-align: center;
					height: 160rpx;
					// background-color: rgba(244, 244, 244, 1);
					border-radius: 8rpx;

					image {
						width: 90rpx;
						height: 90rpx;
					}

					text {
						display: block;
						font-size: 26rpx;
						font-family: Microsoft YaHei;
						font-weight: 400;
						color: #333333;
					}
				}
			}
		}

		.top {
			background-size: 100% 100%;
			background-repeat: no-repeat;
			// : 20rpx;
			width: 100%;
			height: 440rpx;

			.top_logo {
				margin-top: 50rpx;
				margin-bottom: 58rpx;
				width: 480rpx;
				height: 116rpx;
			}

			.ziti {
				text {
					font-size: 28rpx;
					font-family: Source Han Serif CN;
					font-weight: 500;
					color: #91D5C7;
				}

				text:nth-of-type(2) {
					margin: 0 10rpx 0 10rpx;
				}
			}
		}

	}
</style>
